package com.dxq.test.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.dxq.test.common.AppManager;
import com.dxq.test.R;
import com.dxq.test.db.TablesDao;

/**
 * Author: zsh
 * Date: 2023/11/18
 * Describe: 饲喂管理页面
 */
public class FeedOperateActivity extends AppCompatActivity implements View.OnClickListener {

    public TablesDao tablesDao;

    private ImageView ivBack, ivMore;
    private TextView tvTitle;
    private LinearLayout llFood, llFeed;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //添加Activity到堆栈
        AppManager.getAppManager().addActivity(this);
        setContentView(R.layout.activity_feed_operate);
        initView();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //在appManager结束当前activity
        AppManager.getAppManager().finishActivity(this);
    }

    private void initView() {
        ivBack = findViewById(R.id.ivBack);
        ivMore = findViewById(R.id.ivMore);
        tvTitle = findViewById(R.id.tvTitle);
        tvTitle.setText("饲喂管理");
        llFood = this.findViewById(R.id.llFood);
        llFeed = this.findViewById(R.id.llFeed);

        ivBack.setOnClickListener(this);
        llFood.setOnClickListener(this);
        llFeed.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Intent intent = null;
        switch (v.getId()) {
            case R.id.ivBack:
                FeedOperateActivity.this.finish();
                break;

            case R.id.llFood://饲料信息
                intent = new Intent(FeedOperateActivity.this, FoodActivity.class);
                startActivity(intent);
                break;

            case R.id.llFeed://饲喂信息
                intent = new Intent(FeedOperateActivity.this, FeedActivity.class);
                startActivity(intent);
                break;
        }
    }

    @Override
    public void onBackPressed() {
        this.finish();
    }
}
